﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
[CustomEditor(typeof(MaterialModifier))]
public class MaterialModifierEditor : E_ShowButtons<MaterialModifier> { }
#endif
[ExecuteInEditMode]
public class MaterialModifier : MonoBehaviour
{
    public string propName = "_Outline_Width";
    //public Material[] mats;
    public float value;
    public bool update;
    [ShowButton]
    void ApplyValue()
    {
        foreach (var r in GetComponentsInChildren<Renderer>(true))
        {
            foreach (var mat in r.sharedMaterials)
            {
                mat.SetFloat(propName, value);
            }
        }
        //foreach (var mat in mats)
        //{
        //    mat.SetFloat(propName, value);
        //}
    }
    void Update()
    {
        if (update) ApplyValue();
    }
}
